package com.oauth.global.server.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.oauth.global.client.beans.AppInfoBean;
import com.oauth.global.client.beans.BirthdayClientBean;
import com.oauth.service.application.global.beans.Birthday;
import com.oauth.service.application.registry.beans.ApplicationInfoBean;

public class GlobalUtil {

	public static List<AppInfoBean> convertToClientList(
			Collection<ApplicationInfoBean> pInfoBeanList) {
		List<AppInfoBean> imageUrlList = new ArrayList<AppInfoBean>();
		for (ApplicationInfoBean infoBean : pInfoBeanList) {
			imageUrlList.add(convertToClientBean(infoBean));
		}
		return imageUrlList;
	}

	public static AppInfoBean convertToClientBean(ApplicationInfoBean pInfoBean) {
		return new AppInfoBean(pInfoBean.getIconUrl(), pInfoBean.getKey(), pInfoBean.getName());
	}

	public static List<BirthdayClientBean> convertToBirthdayList(List<Birthday> pBirthdayList) {
		List<BirthdayClientBean> list = new ArrayList<BirthdayClientBean>();
		if (pBirthdayList != null) {
			for (Birthday birthday : pBirthdayList) {
				BirthdayClientBean clientBean = new BirthdayClientBean();
				clientBean.setAppIconUrl(birthday.getApplicationIconUrl());
				clientBean.setBirthday(birthday.getBirthDay());
				clientBean.setName(birthday.getDisplayName());
				clientBean.setProfileUrl(birthday.getProfileUrl());
				clientBean.setPictureUrl(birthday.getPictureUrl());
				list.add(clientBean);
			}
		}
		return list;
	}
}
